<?
if(!file_exists(dirname(__FILE__) . "/install/install.lock"))
{
    header("Location:install/index.php");
    exit();
}
include_once('conn.php');
	if($_POST or $_GET){
		$value=$_POST==TRUE?$_POST:$_GET;
		errorchars($value);
		}
		//
include_once('include/browser_class.php');
$temp_name=htmlspecialchars($_POST['name']);
$temp_pw=htmlspecialchars($_POST['pw']);
$temp_vcode=htmlspecialchars($_POST['vcode']);
if(isset($_GET[forgotpw])){
	$result = $db->select("select email,uid from ".tablepre."user where email = '".$_GET['forgotpw']."'");
	
	if($result[0][0]<>null){include('include/checkmail.php'); echo '<script> alert("'.SITE_FORGOT_NOTE_2.'"); location="./";</script>';}else{echo '<script> alert("'.SITE_FORGOT_EMAIL_ERROR.' '.SITE_CONTACT_ADMINISTRATOR.'"); location="./";</script>';
	exit;
	}
	}

if ($_POST){
	ob_start(); 
	setcookie("name",addslashes($temp_name),time()+21600);
	setcookie("pw",md5(addslashes($temp_pw)),time()+21600);
	setcookie("vcode",$temp_vcode,time()+21600);
header("Location: ./user_main.php");
exit;
}
//

if(isset($_GET[out])){
		setcookie("name",'');
	setcookie("pw", '');
	header("Location: ./index.php");
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><? echo systemname;?></title>
<style type="text/css">
<!--
body,td,th {
	font-size: 12px;
	color: #333;
}
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
a:link {
	color: #333;
}
a:visited {
	color: #333;
}
a:hover {
	color: #666;
}
a:active {
	color: #666;
}
-->
</style>
        <script type="text/javascript">
            function myfun()
            {
                var cha1;
                cha1=document.myform.name.value;
                if(cha1=="")
                {
                    alert("<? echo SITE_LOGIN_ERROR_ID;?>!");
                    return false;
                }
				var cha2;
				cha2=document.myform.pw.value;
				if(cha2=="")
				{
				    alert("<? echo SITE_LOGIN_ERROR_PASSWORD;?>");
				    return false;
				}
				var cha3;
				cha3=document.myform.vcode.value;
				if(cha3=="")
				{
				    alert("<? echo SITE_LOGIN_ERROR_AUTH_CODE;?>");
				    return false;
				}
			}
        </script>
</head>

<body>
<div style="background:url(images/t_bg.gif) repeat-x; height:125px;"><img src="images/ttfjpg.php?t=<? echo systemname;?>&bg=logobg.jpg&z=20&x=5&y=60&r=255&b=255&g=255"  /></div>
<form name="myform" method="POST" onSubmit="return myfun()">
  <table width="500" height="169" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td colspan="2"  align="center"><?
      echo check_browser();
	  ?></td>
    </tr>
    <tr>
      <td colspan="2"  align="center"><? echo SITE_LOGIN;?></td>
    </tr>
    <tr>
      <td width="224" height="38"  align="right"><p><? echo SITE_ID;?>&nbsp;&nbsp;</p>      </td>
      <td width="276"><p>
        <input type="text" name="name" /> 
      </p>      </td>
    </tr>
    <tr>
      <td height="38" align="right"><? echo SITE_PASSWORD;?>&nbsp;&nbsp;</td>
      <td><input type="password" name="pw" /></td>
    </tr>
    <tr>
      <td height="38" align="right"><? echo SITE_AUTH_CODE;?>&nbsp;&nbsp;</td>
      <td><input type="text" name="vcode" /><img src="vcode.php" align="absmiddle" /></td>
    </tr>
    <tr>
      <td align="right">&nbsp;</td>
      <td><input type="submit" value="<? echo SITE_LOGIN;?>" /></td>
    </tr>
    <tr>
      <td align="right">&nbsp;<script>
	  function check(){
		  var value = document.getElementById('forgotmail').value;
		     
    if(value.search("^(?:\\w+\\.?)*\\w+@(?:\\w+\\.?)*\\w+$")!=0){
        alert("<? echo SITE_FORGOT_EMAIL_ERROR; ?>!");
        document.forms[0].email.select();
        return false;
    }
		  
		
		  location='?forgotpw='+value;
		  
	  }
	  
	  function forgot()
{
var tab = document.getElementById('tab');//获取id=aa这个元素对象

tab.innerHTML='<? echo SITE_FORGOT_NOTE; ?><br /><input type="text" id="forgotmail" /> <a onClick="check()" style="text-decoration:underline;" href="javascript:void(0);" ><? echo SITE_FORGOT_CHECK;?></a>';
}</script></td>
      <td><a href="javascript:void(0);"  onclick="forgot()" style="text-decoration:underline;"><? echo SITE_FORGOT_PASSWORD;?></a><div id="tab"></div></td>
    </tr>
  </table>
</form>
</body>
</html>
